/**
 * 业务相关
 */

 import { IdValue, SourceData } from "@ugeez/frontend-commons/lib/types";


//公司类型
export enum CompanyType {
    LIMIT = 1,    //有限责任公司
    PARTNERSHIP = 2,    //合伙企业
};

//公司
export type Company = {
    name: string;    //公司名称
    address: string;    //地址
    city: string;    //城市
    province: string;    //省份
    registryTime: number;    //注册时间
    employeeNum: number;    //员工人数
    type: CompanyType;    //公司类型
    biz: SourceData;    //特殊业务数据
    createTime?: number;
    updateTime?: number;
} & IdValue;

export const convertCompany = (obj: SourceData): Company => {
    const item: Company = {
        id: obj.id,
        name: obj.name,
        address: obj.address,
        city: obj.city,
        province: obj.province,
        registryTime: obj.registryTime,
        type: obj.type,
        employeeNum: obj.employeeNum,
        biz: obj.biz || {},
        createTime: obj.createTime,
        updateTime: obj.updateTime,
    };
    return item;
};